let Book = function (id, name, price) {
    //私有属性
    let num = 1;
    //私有方法
    function checkId() {console.log("我是私有方法!");}
    //特权方法
    //注意两类get和set方法的差别。这里name也类似私有属性，price成为公有属性
    this.getName = function () {return name;};
    this.setName = function (nm) {name = nm;};
    this.getPrice = function () {return this.price};
    this.setPrice = function (price) {this.price = price};
    //对象公有属性
    this.id = id;
    //对象公有方法
    this.copy = function () {console.log("我是公有方法!");};
    //构造器。这里不需要对name进行构造
    this.setPrice(price);
};
Book.isChinese = true;
Book.resetTime = function () {console.log("new Time");};
Book.prototype = {
    //公有属性
    isJSBook: false,
    //公有方法
    display: function() {console.log(this.id, this.name, this.price);}
};
let b1 = new Book(11, 'JavaScript设计模式', 50);
console.log(b1.num, b1.isJSBook, b1.id, b1.isChinese);
console.log(b1.getName(), b1.name, b1.getPrice(), b1.price);

